function print_pdf(_url,_target) {
	console.log(_url,_target)
	// 通过<script>标签加载，创建访问PDF.js导出的快捷方式。
	var pdfjsLib = window['pdfjs-dist/build/pdf'];

	// 指定workerSrc属性。
	pdfjsLib.GlobalWorkerOptions.workerSrc = './pdf.worker.js?v=0.01';

	// 异步下载PDF
	var loadingTask = pdfjsLib.getDocument(_url);
	loadingTask.promise.then(function(pdf) {
		document.getElementById(_target).innerHTML = "";
		console.log('PDF loaded',pdf)
		for(var i=1;i<=pdf._pdfInfo.numPages;i++){
			fun_load_page(i,pdf,_target);
		}
	}, function(reason) {
		console.error(reason);
	});
}

function fun_load_page(_page_num,_pdf,_target){
	let _container = document.getElementById(_target);
	_pdf.getPage(_page_num).then(function(page) {
		var viewport = page.getViewport({ scale:5 });

		// 准备画布使用PDF页面尺寸
		var canvas = document.createElement('canvas');
		var context = canvas.getContext('2d');
		canvas.height = viewport.height;
		canvas.width = viewport.width;

		page.render({ canvasContext: context, viewport: viewport });
		canvas.style.cssText = "width:100%;height:auto;display:block;margin:0 auto;border-bottom:10px solid #ccc;";
		_container.appendChild(canvas)
	});
}


function fun_get_query_string(key) {
	var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return unescape(r[2]);
	return null;
}
